import requests
import subprocess
import time

SSID = "ZJKUNET"  #WLAN名称
USERNAME = "23150110025"#你的用户名
PASSWORD = "240012" #你的密码
LOGIN_URL = "http://10.255.254.250/a70.htm"#登录验证地址
data = {#不用动
    "DDDDD": USERNAME,
    "upass": PASSWORD,
    "R1": "0",          
    "R3": "0",          
    "R6": "0",
    "para": "00",
    "0MKKey": "123456",  
    "buttonClicked": "",
    "redirect_url": "",
    "err_flag": "",
    "username": "",
    "password": "",
    "user": "",
    "cmd": "",
    "Login": "",         
    "v6ip": ""
}

print(f"正在连接 {SSID} ...")
subprocess.run(["netsh", "wlan", "connect", f"name={SSID}"], check=True)
time.sleep(5)
session = requests.Session()
response = session.post(LOGIN_URL, data=data)
if "认证成功页" in response.text or "UID='" + USERNAME + "'" in response.text:
    print("登录成功！")
    print("用户信息:", response.text[response.text.find("UID='"):response.text.find("'", response.text.find("UID='")+5)])
    print("完整响应内容：", response.text)
else:
    print("登录失败，请检查参数：")
    print("请求体:", data)
    print("响应内容:", response.text)

